﻿using System;
using System.Collections.Generic;

namespace com.foxmail.wyyuan1991.Assignment
{
    //配流网络的一种简单实现
    public class Arc : IArc
    {
        private double m_Capacity = 999d;

        public Arc()
        {
            //Capacity = -1;//为-1表示无能力限制
        }
        public string ID{get; set;}
        public INode SNode { get; set; }
        public INode ENode { get; set; }


        //public double Capacity { get; set; }
        public Func<double, double> PerformaceFunction { get; set;}
        public double Capacity
        {
            get
            {
                return m_Capacity;
            }
            set
            {
                m_Capacity = value;
            }
        }

        //public double Load { get; set; }
        //public double Cost
        //{
        //    get
        //    {
        //        return PerformaceFunction(this.Load);
        //    }
        //}
        public override string ToString()
        {
            return ID.ToString()+":"+this.SNode.ID+"->"+this.ENode.ID;
        }
    }
    public class Node : INode
    {
        public Node(string _id)
        {
            this.ID = _id;
            ArcList = new List<IArc>();
        }
        public IList<IArc> ArcList { get; set; }
        public string ID { get; set; }

        public override string ToString()
        {
            return ID.ToString();
        }
    }
    public class Network : INetwork
    {
        public IList<IArc> ArcList { get; set; }
        public IList<INode> NodeList { get; set; }
    }
    public class Flow : IDemand
    {
        public INetwork Network { get; set; }
        public IList<IDistributionOD> ODFlowList { get; set; }

    }
    public class ODFlow : IDistributionOD
    {
        public INode DesNode { get; set; }
        public int Num { get; set; }
        public INode OrgNode { get; set; }

        public override string ToString()
        {
            return OrgNode.ToString() + "->" + DesNode + ":" + Num.ToString();
        }
    }
}
